<!--  -->
<template>
  <div>
    <li>
      <label>
        <input type="checkbox"
               :checked="item.done"
               @click="changeItem(item.id)" />

        <!-- @click="item.done=!item.done" -->
        <span>{{item.hobby}}</span>
      </label>
      <button class="btn btn-danger"
              @click="deleteI(item.id)">删除</button>
    </li>
  </div>
</template>

<script>
export default {
  data () {
    return {

    }
  },
  // props: {
  //   "item": {
  //     type: Object,
  //     require: true,
  //     default: {}
  //   }
  // },
  props: ['deleteItem', 'item', 'changeItemStatus'],
  methods: {
    deleteI (id) {
      let bool = confirm("你确定要删除吗?");
      if (bool) {
        this.deleteItem(id)
      }
    },
    changeItem (id) {
      this.changeItemStatus(id)
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created () {

  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted () {

  }
}
</script>
<style scoped>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}
li:hover button {
  display: block;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}
</style>